﻿using System.ComponentModel.DataAnnotations;
using FluentNHibernate.Mapping;

namespace MVVMtutorialAdvanced.Web
{
	public class Author: EntityBase<Author>
	{
		//[Key]
		//[Display(Order = 3)]
		//public virtual int Id { get; set; }

		[Required(AllowEmptyStrings = false, ErrorMessage = "Muss- Feld")]
		[StringLength(20, ErrorMessage = "Maximal 20 Buchstaben")]
		[RegularExpression("[A-Za-z0-9 ]*", ErrorMessage = "Nur A-z und Zahlen")]
		[Display(
			Name = "Vorname",
			Description = "Dies ist der Vorname",
			Prompt = "Prompt Vorname",
			Order = 2,
			AutoGenerateField = false)]
		public virtual string FirstName { get; set; }

		[Required(AllowEmptyStrings = false, ErrorMessage = "Muss- Feld")]
		[StringLength(20, ErrorMessage = "Maximal 20 Buchstaben")]
		[RegularExpression("[A-Za-z0-9 ]*", ErrorMessage = "Nur A-z und Zahlen")]
		[Display(
			Name = "Nachname",
			Description = "Dies ist der Nachname",
			Prompt = "Prompt Nachname",
			Order = 1)]
		public virtual string LastName { get; set; }
	}

	public class AuthorMap : ClassMap<Author>
	{
		public AuthorMap()
		{
			Id(x => x.Id);
			Map(x => x.FirstName);
			Map(x => x.LastName);
		}
	}
}